//
//  LZRushCouponDetialMealsTimeCell.m
//  LzzizDemo
//
//  Created by xbnzd on 16/11/7.
//  Copyright © 2016年 xbnzd. All rights reserved.
//

#import "LZFightGroupDetailMealsTimeCell.h"
#import "GiftListLabel.h"

@interface LZFightGroupDetailMealsTimeCell()

@property (weak, nonatomic) IBOutlet UILabel *labMealTime;          // 用餐时间

@property (weak, nonatomic) IBOutlet UILabel *validExceptTitle;
@property (weak, nonatomic) IBOutlet UILabel *validExceptLabel;    //是否有列外日期

@property (weak, nonatomic) IBOutlet UILabel *everydayValidTitle;
@property (weak, nonatomic) IBOutlet UILabel *everydayValidLabel; //每天工作时间

@property (weak, nonatomic) IBOutlet GiftListLabel *otherContentLabel;  //其他备注

@end

@implementation LZFightGroupDetailMealsTimeCell

- (void)awakeFromNib {
    [super awakeFromNib];
   
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    [self configureLabel];
    self.labMealTime.text = LZLocalizedString(@"group_meal_time", nil);
    self.validExceptTitle.text = LZLocalizedString(@"mine_coupons_valid_except", nil);
    self.everydayValidTitle.text = LZLocalizedString(@"mine_coupons_everyday_valid", nil);
    
    self.validExceptLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 40 - [self.validExceptTitle intrinsicContentSize].width;
    self.everydayValidLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 40 - [self.everydayValidTitle intrinsicContentSize].width;
    self.otherContentLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 20;
    // Initialization code
}

- (void)loadValidExcept:(NSString *)validExcept EverydayValid:(NSString *)everydayValid otherContent:(NSString *)content
{
    self.validExceptLabel.text = (validExcept.length>0?validExcept:@"none");
    self.everydayValidLabel.text = (everydayValid.length>0?everydayValid:@" ");
    [self setOtherContentLabelText:(content.length>0?content:@" ")];
}


- (void)setOtherContentLabelText:(NSString *)text
{
    if (text.length <= 0) {
        return;
    }
    extern CGFloat textLineSpace;
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    
    [style setLineSpacing:textLineSpace];
    [style setLineBreakMode:NSLineBreakByWordWrapping];
    [style setAlignment:NSTextAlignmentLeft];
    
    [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attStr.length)];
    self.otherContentLabel.attributedText = attStr;
}

#pragma mark -
#pragma mark action
- (void)configureLabel
{
    [self.otherContentLabel setVerticalAlignment:VerticalAlignmentTop];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
